package com.huawei.crm.sample.domain.order.service;

import com.huawei.crm.sample.domain.order.model.aggragate.Order;
import com.huawei.crm.sample.domain.order.model.entity.OrderItem;
import com.huawei.crm.sample.domain.order.repository.OrderRepository;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class OrderDomainService {
    private final OrderRepository orderRepository;

    public OrderDomainService(OrderRepository orderRepository) {
        this.orderRepository = orderRepository;
    }

    public Order placeOrder(String customerId, List<OrderItem> items) {
        Order order = Order.placeOrder(customerId, items);
        orderRepository.save(order);
        return order;
    }
} 